﻿using System;
using System.Collections.Generic;
using System.Diagnostics;

namespace Jacobi.ComponentModel.Decomposition.Test.Stubs
{
    /// <summary>
    /// A test filter that produces a random sequence of numbers.
    /// </summary>
    /// <remarks>Inputs are ignored.</remarks>
    class RandomFilter : FilterBase<PipeData, PipeData>
    {
        private string _name;
        public RandomFilter(string name)
        {
            _name = name;
        }

        protected override IList<PipeData> ProcessInternal(IList<PipeData> inputs)
        {
            Trace.WriteLine(_name, "RandomFilter");

            List<PipeData> outputs = new List<PipeData>(base.Outputs.Count);

            for (int i = 0; i < base.Outputs.Count; i++)
            {
                PipeData data = new PipeData();

                Random rnd = new Random((int)DateTime.Now.Ticks);

                rnd.NextBytes(data.Buffer);

                outputs.Add(data);
            }

            return outputs;
        }
    }
}
